package com.hunttown.mes.rpc.domain.enums.task;

import java.util.HashMap;
import java.util.Map;

/**
 * 任务限时
 * created by wangjunfu on 2018/11/6
 */
public enum LimitTypeEnum {
    MINUTES30(30, "30分钟"),
    HOUR1(60, "1小时"),
    HOUR3(180, "3小时"),
    DAY1(1440, "1天"),
    DAY2(2880, "2天"),
    DAY3(4320, "3天"),
    WEEK1(10080, "1周"),
    WEEK2(20160, "2周"),
    MONTH1(43200, "一个月"),
    MONTH3(86400, "三个月"),
    MONTH6(129600, "六个月"),
    YEAR1(525600, "一年");

    private final int key;
    private final String value;

    LimitTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (LimitTypeEnum temp : LimitTypeEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (LimitTypeEnum temp : LimitTypeEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
